LoadBuffer "RAM:__DIYreko_prefsfile__" force /* load the prefs file */
IF rc ~= 0 THEN Call BREAK_RAMPrefsNotFound
Crop (88*i) 0 88 130 /* cut out the correct prefs frame */
Matte 0 0 0 /* put the texture under the frame */
IF cutedge THEN DO
SetPalette '-1' Red Green Blue
Point 0 0
Point 87 0
Point 0 129
Point 87 129
END
Redraw On
SaveBufferAs ILBM tempdir||'__DIYreko_Card'||RIGHT((i+59),2,'0')||'__' force
IF rc ~= 0 THEN Call BREAK_CannotSaveCard
END
END
/* Clean up, because we need as much memory as possible */
Redraw Off
KillBuffer force
swap
KillBuffer force
KillBrush force
Render close
ADDRESS COMMAND 'Protect >NIL: RAM:__DIYreko#?__ ADD d'
ADDRESS COMMAND 'Delete RAM:__DIYreko#?__ QUIET'
ADDRESS COMMAND 'Which >T:__DIYreko_flushfound__ Flush#?' /* find a flush command - I use one and it sometimes saves me some memory, so if the user has it, use it! */
ADDRESS COMMAND 'Execute T:__DIYreko_flushfound__' /* if found, execute it */
ADDRESS COMMAND 'Delete T:__DIYreko#?__ QUIET'
Redraw On
/* Prepare a buffer for rendering the palette */
Redraw Off
CreateBuffer (7 * 88) (4 * 130) force
/* Load images into the buffer side by side
* unfortunately, due to memory limitations, we can only
* load about 30 images, but it should be enough to get
* the correct palette, as long as we select the ones that matter:
* the first three, and if it's an extended cardset, also numbers 55 to 58
* and at least one of the prefs cards in order to get the colours from the
* prefs texture - best use cards 62 and 67 - select card and about card,
* since they contain the most elements which could matter for the
* base colours selection.
*
* If you are one of the lucky people with 10 MB ram or something like that
* feel free to change this part to consider all cards (should be easy enough).
* However, this will only lengthen the processing time and will do little good for
* the quality of the cardset, unless every card is completely different when it
* comes to colours
*/
xp = 0 /* current x position */
yp = 0 /* current y position */
Message "Phase 2 - Preparing palette"
chosenend = 27 /* choose how many standard cards we can take */
IF settype = 1 THEN chosenend = 23
IF settype = 2 THEN chosenend = 21
DO i = 0 TO chosenend
LoadBrush tempdir||'__DIYreko_Card'||RIGHT(i,2,'0')||'__' force
IF rc ~= 0 THEN Call BREAK_TempFileNotFound
BrushHandle 0 0
Point (xp * 88) (yp * 130)
xp = xp + 1
IF (xp > 6) THEN DO
xp = 0
yp = yp + 1
END
END
IF settype > 0 THEN DO
DO i = 55 TO 58
LoadBrush tempdir||'__DIYreko_Card'||RIGHT(i,2,'0')||'__' force
IF rc ~= 0 THEN Call BREAK_TempFileNotFound
BrushHandle 0 0
Point (xp * 88) (yp * 130)
xp = xp + 1
IF (xp > 6) THEN DO
xp = 0
yp = yp + 1
END
END
END
IF settype = 2 THEN DO
DO i = 62 TO 67 BY 5
LoadBrush tempdir||'__DIYreko_Card'||RIGHT(i,2,'0')||'__' force
IF rc ~= 0 THEN Call BREAK_TempFileNotFound
BrushHandle 0 0
Point (xp * 88) (yp * 130)
xp = xp + 1
IF (xp > 6) THEN DO
xp = 0
yp = yp + 1
END
END
END
KillBrush force
/* Prepare rendering module */
SetRender 'Amiga'
Render Mode PAL HIRES HAM LACE
Render Colors 64 /* max number of base colours in HAM8 */
Render Dither 0 0 0 /* no dithering needed in HAM8 */
/* Render the big buffer to obtain the best palette, adjust and lock it */
LockRange 0 off /* unlock the palette - it might have been locked before */
Palette 8 /* we switch to the render palette */
VisibleColors 64 /* show 64 colors on screen - needed to use HAM base colors for rendering */
RenderPalette /* render a palette */
SortPalette Up /* sort it - darkest to lightest */
SetPalette 0 red green blue /* set the background colour */
GetPalette 20 /* move the colours 20 and 24 to the first locations which don't matter too much */
temppalette = result
SetPalette 1 temppalette
GetPalette 24
temppalette = result
SetPalette 2 temppalette
SetPalette 20 darkercolour /* set the now free colours 20 and 24 for the sprites selecting the cards in the game */
SetPalette 24 lightercolour
IF useframe THEN SetPalette 5 framecolour
SetPalette 3 255 0 0 /* red - used for symbols */
SetPalette 4 0 0 1 /* almost black - used for symbols */
SetPalette 5 evendaarkercolour /* these are necessary so that the TONID logo appears sharp :) */
SetPalette 6 evenlightercolour
LockRange 0 on /* lock the render palette so no loaded image can change it and all will use the same one */
VisibleColors 32
KillBuffer force
Redraw On
/* Now reload all the pictures and render them into the correct colours */
Redraw Off
lastcard = 54 /* establish the correct last card number */